import store from '@/store/index.js'
export const  WXLogin = ()=> {
		uni.showModal({
					title:'用于您的页面展示用户头像与昵称',
					content:"是否授权",
					success: () => {
						getWxInfo()
					}
				})
}
  const getWxInfo=()=>{
	  uni.getUserProfile({
		desc:'Wexin',
	  	desc: '用于您的页面展示用户头像与昵称',
	  	lang: 'zh_CN',
	  	success: res => {
			let {userInfo}={...res}
			console.log(res,'userInfouserInfo')
			uni.setStorageSync('token', res.signature)
			store.commit('initUserInfo', userInfo)
			uni.showToast({
				title: '登录成功',
				success() {
					setTimeout(() => {
						uni.switchTab({
							url: 'pages/index/index'
						})
					}, 500)
				}
			})
	  	 
	  	},
	  	fail: err => {
	  		console.log(err.errMsg);
	  	}
	  });
  }